Guys,

I am trying to run the following code.

**********************************************
DECLARE @object int, @outputcd int, @source varchar(255), @description varchar(255), @output varchar(255)

/* Create the COM object */
EXEC @outputcd = sp_OACreate 'ServerA.ClassA', @object OUT /* ServerA is an Inprocess COM server running in SQLserver mem space */
PRINT @outputcd
IF @outputcd <> 0
BEGIN
PRINT &#39;OLE Automation Error Information&#39;
EXEC @outputcd = sp_OAGetErrorInfo @object, @source OUT, @description OUT
IF @outputcd = 0
BEGIN
SELECT @output = &#39; Source1: &#39; + @source
PRINT @output
SELECT @output = &#39; Description: &#39; + @description
PRINT @output
END
PRINT &#39;ERR&#39;
END
PRINT &#39;DONE&#39;

EXEC @outputcd = sp_OADestroy @object
PRint @outputcd

*************************************************
It works OK first time i run it. From next time, I get the following message.

-2147221164
OLE Automation Error Information
Source1: ODSOLE Extended Procedure
Description: Class not registered
ERR
-2147211480

If i restart it, it works ok again the first time. Any clues why this happens? I lost two days fighting this issue.

Thanks for reading
VT